package com.haizhi.crm.api.controller.recommend;

import com.haizhi.crm.common.constant.CrmSchema;
import com.haizhi.crm.common.model.Response;
import com.haizhi.crm.recommend.constant.RecType;
import com.haizhi.crm.recommend.engine.RecEngine;
import com.haizhi.crm.recommend.model.RecQo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by yangyijun on 2018/7/10.
 */
@Api(description = "[产品-推荐]" )
@RestController
@RequestMapping("/productRec" )
public class ProductRecController {
    @Autowired
    private RecEngine recEngine;

    @ApiOperation(value = "产品推荐栏最近浏览" )
    @GetMapping(path = "/recentView" )
    public Response recentView() {
        return recEngine.recommend(new RecQo(CrmSchema.CRM, RecType.Product.SEARCH_RECENT_VIEW, null));
    }

    @ApiOperation(value = "产品推荐栏最近一周热搜产品榜" )
    @GetMapping(path = "/hotSearch" )
    public Response hotSearch() {
        return recEngine.recommend(new RecQo(CrmSchema.CRM, RecType.Product.SEARCH_HOT_SEARCH, null));
    }

    @ApiOperation(value = "产品推荐栏新上架产品" )
    @GetMapping(path = "/newProduct" )
    public Response newProduct() {
        return recEngine.recommend(new RecQo(CrmSchema.CRM, RecType.Product.SEARCH_NEW_PRODUCT_SEARCH, null));
    }

    @ApiOperation(value = "产品推荐栏热度top5" )
    @GetMapping(path = "/hotTop5" )
    public Response hotTop5() {
        return recEngine.recommend(new RecQo(CrmSchema.CRM, RecType.Product.SEARCH_HOT_TOP5_SEARCH, null));
    }
}
